using System;
using System.Globalization;
using System.Windows.Data;
using System.Windows.Media;

using EMan.Interface.EntityEditing;

namespace EMan.GUI.Common.Converters
{
  public class CommentTypeToColorConverter : IValueConverter
  {
    public CommentTypeToColorConverter()
    {
      NormalColor = Colors.Black;
      WarningColor = Colors.BlueViolet;
      ErrorColor = Colors.Red;
    }

    public Color NormalColor{ get; set; }
    public Color WarningColor{ get; set; }
    public Color ErrorColor{ get; set; }

    public object Convert( object value, Type targetType, object parameter, CultureInfo culture )
    {
      var commentType = ( CommentType )value;
      Color result;
      switch( commentType )
      {
        case CommentType.Normal:
          result = NormalColor;
          break;
        case CommentType.Warning:
          result = WarningColor;
          break;
        case CommentType.Error:
          result = ErrorColor;
          break;
        default:
          throw new ArgumentOutOfRangeException();
      }
      return new SolidColorBrush( result );
    }

    public object ConvertBack( object value, Type targetType, object parameter, CultureInfo culture )
    {
      throw new NotSupportedException();
    }
  }
}